package com.cyh.pangu.offer;

import com.cyh.pangu.offer.common.ListNode;

import java.util.Stack;

/**
 * @author cuiyh9
 * @date 2020/8/27
 */
public class Offer06 {



    public int[] reversePrint(ListNode head) {
        Stack<ListNode> stack = new Stack<>();
        while (head != null) {
            stack.push(head);
            head = head.next;
        }
        int size = stack.size();
        int[] rev = new int[size];
        int i = 0;
        while (!stack.isEmpty()) {
            ListNode node = stack.pop();
            rev[i] = node.val;
            i++;
        }
        return rev;
    }

    public static void main(String[] args) {

    }

}
